package com.example.gestioncontacts;

import java.util.ArrayList;
import java.util.List;

import com.example.BD.ContactsDBAdaptateur;
import com.example.metier.Contact;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ApplicationErrorReport.AnrInfo;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class AfficheContacts extends Activity {

	private Button bRetour;
	private ListView list;
	ArrayList<String> listContacts ;

	@SuppressLint("NewApi")
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.affiche_contacts);

		bRetour = (Button) findViewById(R.id.retour);
		list = (ListView) findViewById(R.id.contactList);

		String[] tab = { "Nom+Prenom1", "Nom+Prenom2", "Nom+Prenom3" };
		
		
		ContactsDBAdaptateur cda = new ContactsDBAdaptateur(this);
		cda.open();
		listContacts = cda.getAllNomContacts();
		cda.close();
	
	
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, listContacts);
		list.setAdapter(adapter);

		bRetour.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				Intent i = new Intent(AfficheContacts.this, MainActivity.class);
				startActivity(i);

			}
		});
	}

}
